package leetcode.array;

/**
 * @program: java_learning
 * @description
 * @author: 辛旭初
 * @create: 2020-09-18 09:47
 **/
public class Question7 {

    static public int reverse(int x) {

        String str = x+"";
        boolean flag = false;
        if (str.contains("-")){
            flag = true;
        }
        str = str.replaceAll("-","");
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = str.length()-1; i >=0 ; i--) {
            stringBuilder.append(str.charAt(i));
        }

        if (flag){
            return Integer.parseInt(stringBuilder.toString())*-1;
        }else {
            return Integer.parseInt(stringBuilder.toString());
        }
    }

    public static void main(String[] args) {
//        System.out.println(reverse(9646324351));
    }
}
